package com.simple.gateway.center.domian.application.bo;

import com.simple.gateway.center.basedata.po.ApplicationInterfaceMethod;
import com.simple.gateway.center.domian.application.dto.ApplicationInterfaceMethodDTO;
import com.simple.gateway.center.domian.application.param.ApplicationInterfaceMethodParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 项目: simple-gateway-core
 *
 * 功能描述:
 *
 * @author: WuChengXing
 *
 * @create: 2023-08-07 17:12
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ApplicationInterfaceMethodBO {

    private Long id;

    /**
     * 系统标识
     */
    private String systemId;
    /**
     * 接口标识
     */
    private String interfaceId;
    /**
     * 方法标识
     */
    private String methodId;
    /**
     * 方法名称
     */
    private String methodName;
    /**
     * 参数类型；(RPC 限定单参数注册)；new String[]{"java.lang.String"}、new String[]{"com.simple.gateway.test.provider.rpc.dto.UserRequestDTO"}
     */
    private String parameterType;
    /**
     * 网关接口
     */
    private String uri;
    /**
     * 接口类型；GET、POST、PUT、DELETE
     */
    private String httpCommandType;
    /**
     * true = 1是、false = 0否
     */
    private Integer auth;

    /**
     * 扩展字段
     */
    private String extension;

    public static ApplicationInterfaceMethodBO do2Bo(ApplicationInterfaceMethod applicationInterface) {
        ApplicationInterfaceMethodBO bo = new ApplicationInterfaceMethodBO();
        bo.setId(applicationInterface.getId());
        bo.setSystemId(applicationInterface.getSystemId());
        bo.setInterfaceId(applicationInterface.getInterfaceId());
        bo.setMethodId(applicationInterface.getMethodId());
        bo.setMethodName(applicationInterface.getMethodName());
        bo.setParameterType(applicationInterface.getParameterType());
        bo.setUri(applicationInterface.getUri());
        bo.setHttpCommandType(applicationInterface.getHttpCommandType());
        bo.setAuth(applicationInterface.getAuth());
        bo.setExtension(applicationInterface.getExtension());
        return bo;
    }

    public static ApplicationInterfaceMethod bo2Do(ApplicationInterfaceMethodBO applicationInterfaceMethodBO) {
        ApplicationInterfaceMethod applicationInterfaceMethod = new ApplicationInterfaceMethod();
        applicationInterfaceMethod.setId(applicationInterfaceMethodBO.getId());
        applicationInterfaceMethod.setSystemId(applicationInterfaceMethodBO.getSystemId());
        applicationInterfaceMethod.setInterfaceId(applicationInterfaceMethodBO.getInterfaceId());
        applicationInterfaceMethod.setMethodId(applicationInterfaceMethodBO.getMethodId());
        applicationInterfaceMethod.setMethodName(applicationInterfaceMethodBO.getMethodName());
        applicationInterfaceMethod.setParameterType(applicationInterfaceMethodBO.getParameterType());
        applicationInterfaceMethod.setUri(applicationInterfaceMethodBO.getUri());
        applicationInterfaceMethod.setHttpCommandType(applicationInterfaceMethodBO.getHttpCommandType());
        applicationInterfaceMethod.setAuth(applicationInterfaceMethodBO.getAuth());
        applicationInterfaceMethod.setExtension(applicationInterfaceMethodBO.getExtension());
        return applicationInterfaceMethod;
    }

    public static ApplicationInterfaceMethodDTO bo2Dto(ApplicationInterfaceMethodBO applicationInterfaceMethodBO) {
        ApplicationInterfaceMethodDTO applicationInterfaceMethod = new ApplicationInterfaceMethodDTO();
        applicationInterfaceMethod.setId(applicationInterfaceMethodBO.getId());
        applicationInterfaceMethod.setSystemId(applicationInterfaceMethodBO.getSystemId());
        applicationInterfaceMethod.setInterfaceId(applicationInterfaceMethodBO.getInterfaceId());
        applicationInterfaceMethod.setMethodId(applicationInterfaceMethodBO.getMethodId());
        applicationInterfaceMethod.setMethodName(applicationInterfaceMethodBO.getMethodName());
        applicationInterfaceMethod.setParameterType(applicationInterfaceMethodBO.getParameterType());
        applicationInterfaceMethod.setUri(applicationInterfaceMethodBO.getUri());
        applicationInterfaceMethod.setHttpCommandType(applicationInterfaceMethodBO.getHttpCommandType());
        applicationInterfaceMethod.setAuth(applicationInterfaceMethodBO.getAuth());
        applicationInterfaceMethod.setExtension(applicationInterfaceMethodBO.getExtension());
        return applicationInterfaceMethod;
    }

    public static ApplicationInterfaceMethodBO param2Bo(ApplicationInterfaceMethodParam applicationInterfaceMethodParam) {
        ApplicationInterfaceMethodBO bo = new ApplicationInterfaceMethodBO();
        bo.setSystemId(applicationInterfaceMethodParam.getSystemId());
        bo.setInterfaceId(applicationInterfaceMethodParam.getInterfaceId());
        bo.setMethodId(applicationInterfaceMethodParam.getMethodId());
        bo.setMethodName(applicationInterfaceMethodParam.getMethodName());
        bo.setParameterType(applicationInterfaceMethodParam.getParameterType());
        bo.setUri(applicationInterfaceMethodParam.getUri());
        bo.setHttpCommandType(applicationInterfaceMethodParam.getHttpCommandType());
        bo.setAuth(applicationInterfaceMethodParam.getAuth());
        bo.setExtension(applicationInterfaceMethodParam.getExtension());
        return bo;
    }
}
